<template>
  <div>
    <el-tree :data="menus" :props="defaultProps" @node-click="handleNodeClick">
    </el-tree>
  </div>
</template>

<script>
export default {
  data() {
    return {
      menus: [],
      defaultProps: {
        children: "children",
        label: "name",
      },
    };
  },
  methods: {
    handleNodeClick(data) {
      this.$emit('tree-node-click', data);
    },
    getMenus() {
      this.$http({
        url: this.$http.adornUrl("/product/category/list/tree"),
        method: "get",
        params: null,
      }).then(({ data }) => {
        this.menus = data.list;
      });
    },
  },
  created() {
    this.getMenus();
  },
  mounted() {},
};
</script>

<style lang="scss" scoped>
</style>